//在后续的wps版本中，wps的所有枚举值都会通过wps.Enum对象来自动支持，现阶段先人工定义
var WPS_Enum = {
  msoCTPDockPositionLeft: 0,
  msoCTPDockPositionRight: 2
}

function GetUrlPath() {
  // 在本地网页的情况下获取路径
  if (window.location.protocol === 'file:') {
    const path = window.location.href
    // 删除文件名以获取根路径
    return path.substring(0, path.lastIndexOf('/'))
  }

  // 在非本地网页的情况下获取根路径
  const { protocol, hostname, port } = window.location
  const portPart = port ? `:${port}` : ''
  const url = `${protocol}//${hostname}${portPart}`
  console.log(url)
  return url
}

/**
 * 将指定路由路径的页面显示器对话框
 * @param router_path
 * @param title
 * @param width
 * @param height
 * @param isModal
 */
function showDialog(router_path: string, title: string = '对话框', width: number = 400 * window.devicePixelRatio, height: number = 400 * window.devicePixelRatio, isModal: boolean = false) {
  window.Application.ShowDialog(GetUrlPath() + router_path, title, width, height, isModal)
}

export default {
  WPS_Enum,
  GetUrlPath,
  showDialog
}